//
//  WebViewController.swift
//  OnceNectar
//
//  Created by Zhang Dream on 2018/6/27.
//  Copyright © 2018年 com.inwhoop. All rights reserved.
//

import UIKit

class WebViewController: BaseViewController {

    @IBOutlet weak var webView: UIWebView!
    var webUrl: String = ""
    var webTitle: String = ""
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        self.title = webTitle
        self.webView.loadRequest(URLRequest(url: URL(string: webUrl)!))
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    @objc override func shareTap() {
        //        //创建分享消息对象
        //        UMSocialMessageObject *messageObject = [UMSocialMessageObject messageObject];
        //        //创建图片内容对象
        //        UMShareImageObject *shareObject = [[UMShareImageObject alloc] init];
        //        //如果有缩略图，则设置缩略图
        //        shareObject.thumbImage = [UIImage imageNamed:@"icon"];
        //        [shareObject setShareImage:@"https://mobile.umeng.com/images/pic/home/social/img-1.png"];
        //        //分享消息对象设置分享内容对象
        //        messageObject.shareObject = shareObject;
        
        let message:UMSocialMessageObject = UMSocialMessageObject()
        let share: UMShareWebpageObject = UMShareWebpageObject.shareObject(withTitle:webTitle, descr: "", thumImage: nil)
        share.webpageUrl = webUrl
        message.shareObject = share
        
        ONShareManager.setPreDefinePlatforms([NSNumber(integerLiteral: UMSocialPlatformType.wechatSession.rawValue)
            , NSNumber(integerLiteral: UMSocialPlatformType.QQ.rawValue), NSNumber(integerLiteral: UMSocialPlatformType.sina.rawValue), NSNumber(integerLiteral: UMSocialPlatformType.wechatTimeLine.rawValue)])
        ONShareManager.showShareMenuViewInWindowWithPlatformSelectionBlock { (platformType, info) in
            UMSocialManager.default().share(to: platformType, messageObject: message, currentViewController: self) { (shareResponse, error) in
                
                print("111");
                //                completion(shareResponse, error);
            }
        }
        //        ShareView().showShareView()
    }
}
